#!/bin/bash

# 设置脚本执行权限并创建缺失的资源文件

set -e

PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_DIR"

# 设置脚本权限
chmod +x scripts/*.sh

# 创建资源目录
mkdir -p resources/icons

# 创建desktop文件（如果不存在）
if [ ! -f "resources/linux-resource-monitor.desktop" ]; then
    cat > resources/linux-resource-monitor.desktop << EOF
[Desktop Entry]
Name=Linux资源监控器
Comment=Monitor system resources and CPU scheduler
Exec=linux-resource-monitor
Icon=linux-resource-monitor
Terminal=false
Type=Application
Categories=System;Monitor;
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
X-MATE-Autostart-Delay=5
EOF
    echo "Created resources/linux-resource-monitor.desktop"
fi

# 创建占位图标文件（如果不存在）
if [ ! -f "resources/icons/linux-resource-monitor.png" ]; then
    touch resources/icons/linux-resource-monitor.png
    echo "Created placeholder resources/icons/linux-resource-monitor.png"
fi

echo "Setup completed successfully."